package com.example.controller;

import com.example.domain.dto.TimeDTO;
import com.example.domain.po.Chapter;
import com.example.domain.vo.CourseContentVo;
import com.example.service.CourseService;
import com.example.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/courseContent")
public class CourseContentController {

    @Autowired
    CourseService courseService;


    @GetMapping("/getCourseContent")
    public Result<List<CourseContentVo>>getCourseContent(@RequestParam(required = false) Integer courseId , @RequestParam(required = false) String courseName ,
                                                         @RequestParam(required = false)     String doctorName) {
       System.out.println(courseName);
            return Result.success(courseService.getCourseContent(courseId,courseName,doctorName));
    }


    @PostMapping("/addChapter")
    public Result<String> add(@RequestBody Chapter chapter) {

        courseService.addChapter(chapter);
        return Result.success("添加成功");
    }

    @PostMapping("/addTime")
    public Result<String> addTime(@RequestBody TimeDTO timeDTO) {
        courseService.addTime(timeDTO);
        return Result.success("添加成功");
    }

}
